﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Actuals.CoreDomain;
using Actuals.CoreDomain.Data;
using System.Data;
using System.Collections;
using Actuals.Data;

namespace Actuals.Data
{
    public class DalEmpTeamJoinLeave : Dal<IEmpTeamJoinLeave, EmpTeamJoinLeave>, IDalEmpTeamJoinLeave
    {

         private readonly IDalManager _manager;
        private static readonly IDalEmpTeamJoinLeave _instance = new DalEmpTeamJoinLeave();
        private const string SP_GET_TEAM_EMP_JOIN_LEAVE = "usp_GetTeamEmpJoinLeave";

        public static IDalEmpTeamJoinLeave Instance
        {
            get { return _instance; }
        }
        public DalEmpTeamJoinLeave()
        {
            _manager = new DalManager();
        }
        public DalEmpTeamJoinLeave(IDalManager manager)
        {
            _manager = manager;
        }

        protected override void Convert(IEmpTeamJoinLeave obj, DataRow row)
        {
            obj.id = _manager.GetValue<int>(row, "id");
            obj.TeamId = _manager.GetValue<int>(row, "TeamId");
            obj.EmployeeId = _manager.GetValue<int>(row, "EmployeeId");
            obj.StartDate = _manager.GetValue<DateTime>(row, "StartDate");
            obj.Enddate = _manager.GetValue<DateTime>(row, "EndDate");
            obj.NoOfHrs = _manager.GetValue<int>(row, "NoOfHrs");           

        }

       public IList<IEmpTeamJoinLeave> GetDetails( int teamId, 
           DateTime startDate, DateTime endDate)
        {
            _manager.StoredProcedureName = SP_GET_TEAM_EMP_JOIN_LEAVE;
          
            _manager.AddInParameter("@TeamId", DbType.Int32, teamId);
            _manager.AddInParameter("@StartDate", DbType.DateTime, startDate);
            _manager.AddInParameter("@EndDate", DbType.DateTime, endDate);



            IList<IEmpTeamJoinLeave> empTeamJoinLeaves = new List<IEmpTeamJoinLeave>();
            foreach (IEmpTeamJoinLeave empTeamJoinLeave in ConvertAll(_manager.ExecuteDataSet()))
                empTeamJoinLeaves.Add(empTeamJoinLeave);

            return empTeamJoinLeaves;


        }

    }
}
